package org.jeecg.modules.demo.soSettlement.controller;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.gson.Gson;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.aspect.annotation.PermissionData;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.demo.cwSaleInvoice.entity.CwSaleInvoice;
import org.jeecg.modules.demo.cwSaleInvoice.service.ICwSaleInvoiceService;
import org.jeecg.modules.demo.soQualityOrder.entity.SoQualityOrder;
import org.jeecg.modules.demo.soQualityOrder.service.ISoQualityOrderService;
import org.jeecg.modules.demo.soSaleOrder.entity.SoSaleOrder;
import org.jeecg.modules.demo.soSaleOrder.service.ISoSaleOrderService;
import org.jeecg.modules.demo.soSettlement.entity.SoSettlement;
import org.jeecg.modules.demo.soSettlement.service.ISoSettlementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;

/**
 * @Description: 销售结算单
 * @Author: jeecg-boot
 * @Date: 2021-12-15
 * @Version: V1.0
 */
@Api(tags = "销售结算单")
@RestController
@RequestMapping("/sosettlement/soSettlement")
@Slf4j
public class SoSettlementController extends JeecgController<SoSettlement, ISoSettlementService> {
    @Autowired
    private ISoSettlementService soSettlementService;
    @Autowired
    private ISoQualityOrderService soQualityOrderService;

    @Autowired
    private ICwSaleInvoiceService cwSaleInvoiceService;
    @Autowired
    private ISoSaleOrderService soSaleOrderService;
    @Autowired
    private ISysBaseAPI sysBaseAPI;

    private static final String TITLE = "单据审核";


    private String getMessage(String name,String date) {
        String str ="由【"+name+"】于【"+date+"】发起的销售结算单需要您的审核，请及时查看！";
        return str;
    }
    private String getMsg(String name,String date) {
        String str ="由【"+name+"】于【"+date+"】发起的销售发票单需要您的审核，请及时查看！";
        return str;
    }
    /**
     * 分页列表查询
     *
     * @param soSettlement
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "销售结算单-分页列表查询")
    @ApiOperation(value = "销售结算单-分页列表查询", notes = "销售结算单-分页列表查询")
    @GetMapping(value = "/list")
    @PermissionData(pageComponent="yunxiao/sosettlement/SoSettlementList")
    public Result<?> queryPageList(SoSettlement soSettlement,
                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                   HttpServletRequest req) {
        QueryWrapper<SoSettlement> queryWrapper = QueryGenerator.initQueryWrapper(soSettlement, req.getParameterMap());
        queryWrapper.eq("IS_DELETE", 0);
        queryWrapper.ne("JS_TYPE",3);
//        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//        List<String> list = sysBaseAPI.getDepartNamesByUsername(sysUser.getUsername());
//        String deptName= null;
//        if(list.size()>=1){
//            deptName = list.get(0);
//        }
//        if(sysUser.getUsername().equals("admin") || sysUser.getUsername().equals("administrator")||deptName.equals("财务部")){
//            Page<SoSettlement> page = new Page<SoSettlement>(pageNo, pageSize);
//            IPage<SoSettlement> pageList = soSettlementService.page(page, queryWrapper);
//            return Result.OK(pageList);
//        }
//
//        if( sysUser.getUserIdentity()== 2 ){
//            queryWrapper.eq("DEPT",sysUser.getDepartIds());
//        }else {
//            queryWrapper.eq("SOS_STAFF",sysUser.getId());
//        }
        Page<SoSettlement> page = new Page<SoSettlement>(pageNo, pageSize);
        IPage<SoSettlement> pageList = soSettlementService.page(page, queryWrapper);
        return Result.OK(pageList);
    }
    @PostMapping(value = "/getWriteOffDetails")
    public String getWriteOffDetails(@RequestBody SoSettlement soSettlement){
        Gson gson = new Gson();
        Map map = new HashMap();
        try{
            List<SoSettlement> soSettlements = soSettlementService.getWriteOffDetails(soSettlement.getSosNo());
            map.put("code",200);
            map.put("message","查询成功！");
            map.put("soSettlements",soSettlements);
            String json = gson.toJson(map);
            return json;
        }catch (Exception e){
            e.printStackTrace();
            map.put("code",500);
            map.put("message","系统错误！");
            String json = gson.toJson(map);
            return json;
        }
    }
    /**
     * 添加
     *
     * @param soSettlement
     * @return
     */
    @AutoLog(value = "销售结算单-添加")
    @ApiOperation(value = "销售结算单-添加", notes = "销售结算单-添加")
    @PostMapping(value = "/add")
    public Result<?> add(@RequestBody SoSettlement soSettlement) {
        soSettlementService.save(soSettlement);
        return Result.OK("添加成功！");
    }

    //根据订单号查询预结算单
    @GetMapping(value = "/getYjsd")
    public Result<?> getYjsd(@RequestParam(name = "soNo", required = true) String soNo) {
        List<SoSettlement> sos = soSettlementService.getYjsd(soNo);
        return Result.OK(sos);
    }


    //红冲预结算单并生成红冲结算单
    @PostMapping(value = "/hcYjsd")
    public Result<?> hcYjsd(@RequestBody JSONObject jsonObject, HttpServletRequest req) {
        if (soSettlementService.hcYjsd(jsonObject, req)) {
            return Result.OK("操作成功！");
        }
        return Result.error(500, "操作失败！");
    }

    //根据质检单生成结算单
    @PostMapping(value = "/addSoSettle")
    public Result<?> addSoSettle(@RequestBody JSONObject jsonObject, HttpServletRequest req) {
        if (soSettlementService.addSoSettle(jsonObject,req)) {
            return Result.OK("生成结算单成功！");
        }
        return Result.error("生成结算单失败!");

    }

    //根据入库单生成结算单
    @PostMapping(value = "/addPuSettle")
    public Result<?> addPuSettle(@RequestBody JSONObject jsonObject,HttpServletRequest req){
        if (soSettlementService.addPoSettle(jsonObject,req)) {
            return Result.OK("生成结算单成功！");
        }
        return Result.error("生成结算单失败!");
    }


    //根据结算单生成发票单
    @PostMapping(value = "/addSoInvoice")
    public Result<?> addSoInvoice(@RequestBody JSONObject jsonObject, HttpServletRequest req) {
//        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        if (soSettlementService.addSoInvoice(jsonObject,req)) {
            return Result.OK("生成发票单成功！");
        }
        return Result.error("生成发票单失败!");

    }

    //根据结算单生成发票单
//    @PostMapping(value = "/addSoInvoice")
//    public Result<?> addSoInvoice(@RequestBody JSONObject jsonObject) {
//        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//        try {
//            SoSettlement soSettlement = JSON.parseObject(jsonObject.toJSONString(), SoSettlement.class);
//            CwSaleInvoice csi = JSON.parseObject(jsonObject.toJSONString(), CwSaleInvoice.class);
//            SimpleDateFormat soSettlementf = new SimpleDateFormat("yyyyMMdd");
//            String uid_pefix = soSettlementf.format(new Date());
//            List<CwSaleInvoice> list = this.cwSaleInvoiceService.list();
//            Collections.sort(list);
//
//            String max_code = "";
//            if (list.size() > 0) {
//                max_code = list.get(0).getInvoiceNo();
//            }
//            String comment_code = "";
//            if (max_code != null && max_code.contains("XSFP" + uid_pefix)) {
//                String uid_end = max_code.substring(12, 16);
//                int endNum = Integer.parseInt(uid_end);
//                int tmpNum = 10000 + endNum + 1;
//                comment_code = "XSFP" + uid_pefix + this.subStr("" + tmpNum, 1);
//            } else {
//                comment_code = "XSFP" + uid_pefix + "0001";
//            }
//            SoSettlement ssm = soSettlementService.getSoSettleBySosNo(soSettlement.getSosNo());
//            if (csi.getInvoiceNo() == null || csi.getInvoiceNo().isEmpty()) {
//                csi.setId("");
//                csi.setProject(soSettlement.getProject());
//                csi.setDept(ssm.getDept());
//                csi.setSoCustom(ssm.getSoCustom());
//                csi.setInvoiceNo(comment_code);
//                csi.setSosNo(ssm.getSosNo());
//                csi.setSoNo(ssm.getSoNo());
//                csi.setIsDelete(0);
//                csi.setIsSkd(0);
//                csi.setSoStatus(0);
//                csi.setFplx("2");
//                csi.setSyysJine(BigDecimal.valueOf(0));
//                csi.setSkJine(csi.getSkJines());
//                csi.setSupamount(csi.getSkJine());
//                csi.setPrdName(soSettlement.getPrdName());
//                csi.setRealzb(soSettlement.getRealzb());
//                csi.setHsdj(soSettlement.getSosPrice());
//                csi.setHsje(csi.getSkJine());
//                csi.setWsdj(soSettlement.getWsdj());
//                csi.setWsje(soSettlement.getWsje());
//                csi.setScCdate(new Date());
//                csi.setCreateTime(new Date());
////                csi.setFpYs(1);
//                cwSaleInvoiceService.save(csi);
//
////                ssm.setYkpJine(csi.getSkJine());
//                ssm.setWkpJine(ssm.getWkpJine().subtract(csi.getSkJine()));
////                ssm.setIsFpd(1);
//                if (ssm.getWkpJine().compareTo(BigDecimal.valueOf(0)) < 1) {
//                    ssm.setIsFpd(1);
//                }
//                soSettlementService.updateById(ssm);
//
//            } else {
////                if (soSettlement.getWkpJine().compareTo())
//                //本次开票金额大于0
//                if (csi.getSkJines().compareTo(BigDecimal.valueOf(0)) == 1) { //使用预开发票抵消发票金额
//                    CwSaleInvoice cs = cwSaleInvoiceService.getByInvoiceNo(csi.getInvoiceNo());
//
//
//                    CwSaleInvoice cw = new CwSaleInvoice();
//                    cw.setId("");
//                    cw.setSl(soSettlement.getSl());
//                    cw.setInvoiceNo(comment_code);
//                    cw.setSosNo(soSettlement.getSosNo());
//                    cw.setSoNo(cs.getSoNo());
//                    cw.setIsDelete(0);
//                    cw.setIsSkd(0);
//                    cw.setSoStatus(0);
//                    cw.setFplx("2");
//                    cw.setZhName(cs.getZhName());
//                    cw.setJsType(cs.getJsType());
//                    cw.setSkJine(csi.getSkJines());
//                    cw.setSupamount(cw.getSkJine());
//                    cw.setDept(ssm.getDept());
//                    cw.setSoCustom(ssm.getSoCustom());
//                    cw.setPrdName(soSettlement.getPrdName());
////                    cw.setFpYs(2);
//
//                    cw.setFpsl(soSettlement.getFpsl());
//                    cw.setHsdj(soSettlement.getSosPrice());
//
//                    cw.setProject(soSettlement.getProject());
//                    cw.setRealzb(soSettlement.getRealzb());
//                    cw.setSyysJine(BigDecimal.valueOf(0));
//                    cw.setHsje(csi.getSkJines());
//                    cw.setWsdj(soSettlement.getWsdj());
//                    cw.setWsje(soSettlement.getWsdj().multiply(cw.getFpsl()));
//                    cw.setPsTax(cw.getHsje().subtract(cw.getWsje()));
//                    cw.setScCdate(new Date());
//                    cw.setCreateTime(new Date());
//                    cwSaleInvoiceService.save(cw);
//
//                    String uid_end = cw.getInvoiceNo().substring(12, 16);
//                    int endNum = Integer.parseInt(uid_end);
//                    int tmpNum = 10000 + endNum + 1;
//                    comment_code = "XSFP" + uid_pefix + this.subStr("" + tmpNum, 1);
//
//                    CwSaleInvoice cws = new CwSaleInvoice();
//                    cws.setId("");
//                    cws.setSl(soSettlement.getSl());
//                    cws.setInvoiceNo(comment_code);
//                    cws.setSosNo(soSettlement.getSosNo());
//                    cws.setSoNo(cs.getSoNo());
//                    cws.setIsDelete(0);
//                    cws.setIsSkd(0);
//                    cws.setSoStatus(0);
//                    cws.setFplx("3");
//                    cws.setZhName(cs.getZhName());
//                    cws.setJsType(cs.getJsType());
//                    cws.setSkJine(cs.getKkpJine());
//                    cws.setDept(ssm.getDept());
//                    cws.setSoCustom(ssm.getSoCustom());
//                    cws.setPrdName(soSettlement.getPrdName());
//                    cws.setFpsl(soSettlement.getSosTotal());
//                    cws.setHsdj(soSettlement.getSosPrice());
//                    cws.setRealzb(soSettlement.getRealzb());
//                    cws.setSyysJine(BigDecimal.valueOf(0));
//                    cws.setHsje(soSettlement.getHsje());
//                    cws.setWsdj(soSettlement.getWsdj());
//                    cws.setWsje(soSettlement.getWsje());
//                    cws.setPsTax(cw.getHsje().subtract(cw.getWsje()));
//                    cws.setScCdate(new Date());
//                    cws.setCreateTime(new Date());
//                    cwSaleInvoiceService.save(cws);
//
//                    cs.setSosNo(soSettlement.getSosNo());
//                    cs.setSoStatus(1);
//                    cs.setKkpJine(BigDecimal.valueOf(0));
//                    cwSaleInvoiceService.updateById(cs);
//
////                    ssm.setYkpJine(cw.getSkJine().add(csi.getSkJines()));
//                    ssm.setWkpJine(ssm.getWkpJine().subtract(csi.getSkJines()).subtract(cs.getSkJine())); //结算单可开票金额-页面本次开票金额-预开发票未抵扣前的可开票金额（开票金额）
//                    if (ssm.getWkpJine().compareTo(BigDecimal.valueOf(0)) < 1) {
//                        ssm.setIsFpd(1);
//                    }
////                    ssm.setIsFpd(1);
//                    soSettlementService.updateById(ssm);
//                    //本次开票金额小于等于0，结算单应开票金额小于等于预开发票可开票金额时，
//                } else if (csi.getSkJines().compareTo(BigDecimal.valueOf(0)) < 1) { //使用预开发票抵消发票金额
//                    CwSaleInvoice cs = cwSaleInvoiceService.getByInvoiceNo(csi.getInvoiceNo());
////                    cs.setSosNo(soSettlement.getSosNo());
//                    cs.setSoStatus(1);
//                    cs.setKkpJine(cs.getKkpJine().subtract(soSettlement.getWkpJine()));
//
//                    if (cs.getSosNo() == null) {
//                        cs.setSosNo(csi.getSosNo());
//                    } else {
//                        cs.setSosNo(cs.getSosNo() + "," + csi.getSosNo());
//                    }
//
//                    cwSaleInvoiceService.updateById(cs);
//
////                    BigDecimal b = soSettlement.getSosTotal().subtract(csi.getFpsl());
////                    BigDecimal a = csi.getSkJines().divide(b, 3, BigDecimal.ROUND_UP);
//
//                    CwSaleInvoice cw = new CwSaleInvoice();
//                    cw.setId("");
//                    cw.setSl(soSettlement.getSl());
//                    cw.setInvoiceNo(comment_code);
//                    cw.setSosNo(soSettlement.getSosNo());
//                    cw.setSoNo(cs.getSoNo());
//                    cw.setIsDelete(0);
//                    cw.setIsSkd(0);
//                    cw.setSoStatus(0);
//                    cw.setFplx("3");
//                    cw.setZhName(cs.getZhName());
//                    cw.setJsType(cs.getJsType());
//                    cw.setSkJine(soSettlement.getWkpJine());
//                    cw.setDept(ssm.getDept());
//                    cw.setSoCustom(ssm.getSoCustom());
//                    cw.setPrdName(soSettlement.getPrdName());
//                    cw.setFpsl(soSettlement.getSosTotal());
//                    cw.setHsdj(soSettlement.getSosPrice());
//                    cw.setRealzb(soSettlement.getRealzb());
//                    cw.setSyysJine(BigDecimal.valueOf(0));
//                    cw.setHsje(soSettlement.getHsje());
//                    cw.setWsdj(soSettlement.getWsdj());
//                    cw.setWsje(soSettlement.getWsje());
//                    cw.setPsTax(cw.getHsje().subtract(cw.getWsje()));
//                    cw.setScCdate(new Date());
//                    cw.setCreateTime(new Date());
//                    cwSaleInvoiceService.save(cw);
//
////                    ssm.setYkpJine(csi.getSkJines());
////                    ssm.setWkpJine(ssm.getSosAmount().subtract(ssm.getYkpJine()));
//                    ssm.setYkpNo(csi.getInvoiceNo());//只针对结算金额小于预开票金额的结算单使用
////                    ssm.setYkpJine();
//                    ssm.setWkpJine(BigDecimal.valueOf(0.00));
////                    ssm.setWkpJine(ssm.getWkpJine().subtract(csi.getSkJine()));
//                    if (ssm.getWkpJine().compareTo(BigDecimal.valueOf(0)) < 1) {
//                        ssm.setIsFpd(1);
//                    }
////                    ssm.setIsFpd(1);
//                    soSettlementService.updateById(ssm);
//                    return Result.OK("已使用预收抵消发票金额,生成红冲发票!");
//                }
//            }
//            return Result.OK("生成发票单成功!");
//        } catch (Exception e) {
//            log.error(e.getMessage(), e);
//            return Result.error("操作失败");
//        }
//    }

    /**
     * 编辑
     *
     * @param soSettlement
     * @return
     */
    @AutoLog(value = "销售结算单-编辑")
    @ApiOperation(value = "销售结算单-编辑", notes = "销售结算单-编辑")
    @PutMapping(value = "/edit")
    public Result<?> edit(@RequestBody SoSettlement soSettlement) {
        try {
            soSettlement.setSosAmount(soSettlement.getHsje());
            soSettlement.setWkpJine(soSettlement.getHsje());
            if (soSettlement.getFj() == null || soSettlement.getFj().equals("")) {
                soSettlement.setHqzy(0);
            } else {
                soSettlement.setHqzy(1);
            }
            soSettlementService.updateById(soSettlement);
            return Result.OK("编辑成功!");
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return Result.error("编辑失败");
        }
    }

    //审核
    @PutMapping(value = "/editShenhe")
    public Result<?> editShenhe(@RequestBody SoSettlement soSettlement) {
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        try {
            if (!soSettlement.getShName().equals(sysUser.getId())){
                return Result.error(300,"您无此权限！");
            }
            if (soSettlement.getSoStatus() == 0) {
                soSettlement.setShTime(null);
                List<CwSaleInvoice> cw = cwSaleInvoiceService.getlistBySosNo(soSettlement.getSosNo());
                if (cw.size() > 0){
                    return Result.error(300,"此结算单已生成发票，请先删除发票再弃审!");
                }
            } else {
//            soSettlement.setShName(sysUser.getRealname());
                soSettlement.setShTime(new Date());
            }
            soSettlementService.updateById(soSettlement);
            return Result.OK("操作成功!");
        }catch (Exception e){
            log.error(e.getMessage(), e);
            return Result.error("操作失败!");
        }
    }

    //假删除加修改上级质检单状态
    @PutMapping(value = "/editsqoStatus")
    public Result<?> editsqoStatus(@RequestBody SoSettlement soSettlement) {

        //1普通结算 2预结算 3红字
        if (soSettlement.getJsType() == 1 || soSettlement.getJsType() == 4) {
            if (soSettlement.getSoqNo() != null) {
                String[] soq = soSettlement.getSoqNo().split(",");
                for (String sq : soq) {
                    SoQualityOrder so = soQualityOrderService.editsqoStatus(sq);
                    so.setChuku(0);
                    if (so.getQoQuantity().compareTo(so.getSyNum()) == 1){  //质检单质检数量>剩余质检数量
                        so.setChuku(2);
                    }

                    soQualityOrderService.updateById(so);
                }
            }


        } else if (soSettlement.getJsType() == 3) {
            SoQualityOrder so = soQualityOrderService.editsqoStatus(soSettlement.getSoqNo());
            SoSaleOrder ss = soSaleOrderService.getBysoNo(so.getSoOrder());
            so.setChuku(0);
            so.setSyNum(so.getSyNum().add(soSettlement.getSosTotal()));

            ss.setKjskpNum(ss.getKjskpNum().add(soSettlement.getSosTotal()));
            //恢复预结算单
            SoSettlement set = soSettlementService.getBySosNo(soSettlement.getHxNo());
            set.setKjsJine(set.getKjsJine().add(soSettlement.getSosTotal().multiply(set.getSosPrice())));
            set.setKjsNum(set.getKjsNum().add(soSettlement.getSosTotal()));
            soSettlementService.updateById(set);
            ss.setKjsJine(ss.getKjsJine().add(soSettlement.getSosTotal().multiply(set.getSosPrice())));
            soSaleOrderService.updateById(ss);
            soQualityOrderService.updateById(so);
        }

        soSettlementService.removeById(soSettlement);
        return Result.OK("删除成功!");
    }
//    @PutMapping(value = "/editsqoStatus")
//    public Result<?> editsqoStatus(@RequestBody SoSettlement soSettlement) {
//        String qoNum = soSettlement.getSoqNo();
//        if (qoNum != null) {
//            String[] soq = qoNum.split(",");
//            for (String sq : soq) {
//                SoQualityOrder so = soQualityOrderService.editsqoStatus(sq);
//                so.setChuku(0);
////			 so.setQoQuantity(so.getQoQuantity().add(soSettlement.getKouton()));
//                soQualityOrderService.updateById(so);
//            }
//        }
//
////		 SoQualityOrder so = soQualityOrderService.editsqoStatus(soSettlement.getSoqNo());
////		 so.setChuku(0);
//        soSettlementService.updateById(soSettlement);
////		 soQualityOrderService.updateById(so);
//        return Result.OK("删除成功!");
//    }

    /**
     * 通过id删除
     *
     * @param id
     * @return
     */
    @AutoLog(value = "销售结算单-通过id删除")
    @ApiOperation(value = "销售结算单-通过id删除", notes = "销售结算单-通过id删除")
    @DeleteMapping(value = "/delete")
    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
        soSettlementService.removeById(id);
        return Result.OK("删除成功!");
    }

    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    @AutoLog(value = "销售结算单-批量删除")
    @ApiOperation(value = "销售结算单-批量删除", notes = "销售结算单-批量删除")
    @DeleteMapping(value = "/deleteBatch")
    public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
        this.soSettlementService.removeByIds(Arrays.asList(ids.split(",")));
        return Result.OK("批量删除成功!");
    }

    /**
     * 通过id查询
     *
     * @param id
     * @return
     */
    @AutoLog(value = "销售结算单-通过id查询")
    @ApiOperation(value = "销售结算单-通过id查询", notes = "销售结算单-通过id查询")
    @GetMapping(value = "/queryById")
    public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
        SoSettlement soSettlement = soSettlementService.getById(id);
        if (soSettlement == null) {
            return Result.error("未找到对应数据");
        }
        return Result.OK(soSettlement);
    }

    /**
     * 导出excel
     *
     * @param request
     * @param soSettlement
     */
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, SoSettlement soSettlement) {
        return super.exportXls(request, soSettlement, SoSettlement.class, "销售结算单");
    }

    /**
     * 通过excel导入数据
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        return super.importExcel(request, response, SoSettlement.class);
    }

}
